package com.library.service.impl;


import com.library.common.core.domain.BaseEntity;
import com.library.common.core.text.Convert;
import com.library.domain.MbGoods;
import com.library.mapper.MbGoodsMapper;
import com.library.service.IMbGoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 积分商城 服务层实现
 *
 * @author null
 * @date 2020-04-23
 * @blame Android Team
 */
@Service
public class MbGoodsServiceImpl implements IMbGoodsService {
    @Resource
    private MbGoodsMapper mbGoodsMapper;


    /**
     * 查询积分商城信息
     *
     * @param id 积分商城ID
     * @return 积分商城信息
     */
    @Override
    public MbGoods selectMbGoodsById(Long id) {
        return mbGoodsMapper.selectMbGoodsById(id);
    }

    /**
     * 查询积分商城列表
     *
     * @param mbGoods 积分商城信息
     * @return 积分商城集合
     */
    @Override
    public List<MbGoods> selectMbGoodsList(MbGoods mbGoods) {
        return mbGoodsMapper.selectMbGoodsList(mbGoods);
    }

    /**
     * 新增积分商城
     *
     * @param mbGoods 积分商城信息
     * @return 结果
     */
    @Override
    public int insertMbGoods(MbGoods mbGoods) {
        return mbGoodsMapper.insertMbGoods(mbGoods);
    }

    /**
     * 修改积分商城
     *
     * @param mbGoods 积分商城信息
     * @return 结果
     */
    @Override
    public int updateMbGoods(MbGoods mbGoods) {
        return mbGoodsMapper.updateMbGoods(mbGoods);
    }

    /**
     * 删除积分商城对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMbGoodsByIds(Long[] ids) {
        for (Long id : ids) {
            MbGoods mbGoods = mbGoodsMapper.selectMbGoodsById(id);
            if (null == mbGoods)
                continue;
            mbGoods.setIsDelete(BaseEntity.DELETE);
            mbGoodsMapper.updateMbGoods(mbGoods);
        }
        return BaseEntity.DELETE;
    }

}
